<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./12封装Promise原理.js"></script>
  <script>
    const p = new myPromise((resolve, reject) => {
      setTimeout(() => {
        let data = '数据库中的用户初始数据';
        resolve(data); // 此时调用resolve就执行存储的成功的回调
      }, 1000);
      // resolve('123')
    });

    // 处理异步编程时，状态并未改变，所以需要先将成功、失败的回调函数保存起来
    p.then(value => {
      console.log(value);
    }, err => {
      console.log(err);
    })

  </script>
</body>

</html>